package cn.com.pagoda.ideplugin.service.pwdGen.service.impl;

import cn.com.pagoda.ideplugin.service.pwdGen.service.PasswordGenerator;

import java.util.Random;

/**
 * 特殊符号
 * @author Mch
 * @date 2023-05-27
 */
public class SpecialCharacterPasswordGenerator implements PasswordGenerator {
    private static final String SPECIAL_CHARACTERS = "!@#$%^&*()_+-=[]{};':\"\\|,.<>/?"; // 特殊字符集合

    @Override
    public String generatePassword(int length) {
        StringBuilder password = new StringBuilder();
        Random random = new Random();
        for (int i = 0; i < length; i++) {
            password.append(SPECIAL_CHARACTERS.charAt(random.nextInt(SPECIAL_CHARACTERS.length()))); // 从特殊字符集合中随机选择字符
        }
        return password.toString();
    }
}
